package com.qingcheng.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.pojo.seckill.SeckillGood;
import com.qingcheng.service.seckill.SeckillGoodsService;
import com.qingcheng.utils.DateUtil;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * Created by yuanxin
 * Date:2019/7/22
 * Time:16:48
 */
@RestController
@RequestMapping("/seckill/goods")
public class SeckillGoodsController {
    @Reference
    private SeckillGoodsService seckillGoodsService;

    /**
     * /seckill/goods/menus
     * 获取时间菜单
     *
     * @return
     */
    @GetMapping("/menus")
    public List<Date> dateMenus() {
        return DateUtil.getDateMenus();
    }


    /**
     * URL:/seckill/goods/list
     * 加载对应时间的商品列表
     *
     * @param time
     * @return
     */
    @RequestMapping("/list")
    public List<SeckillGood> list(String time) {
        return seckillGoodsService.list(time);
    }

    /**
     *  URL:/seckill/goods/one
     * 根据ID查询商品详情
     * @param time
     * @param id
     * @return
     */
    @GetMapping("/one")
    public SeckillGood  one(String time,Long id){
       return seckillGoodsService.one(time,id);
    }
}
